package com.faiz.algorithm;

import java.util.Deque;
import java.util.LinkedList;

public class IsPalindrome {
    // 方法1： 使用双端队列
    public boolean isPalindarome(ListNode head) {
        Deque<Integer> deque = new LinkedList();
        while (head != null) {
            deque.offerLast(head.val);
            head = head.next;
        }
        int l, r;
        while (deque.size() >= 2) {
            l = deque.pollFirst();
            r = deque.pollLast();
            if (l != r) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        IsPalindrome isPalindrome = new IsPalindrome();
        ListNode head = new ListNode(1);
        System.out.println(isPalindrome.isPalindarome(head));
    }

}
